<?php
/*********************************************
 *  CPG Dragonfly™ CMS
 *********************************************
	Copyright © since 2010 by CPG-Nuke Dev Team
	http://dragonflycms.org

	Dragonfly is released under the terms and conditions
	of the GNU GPL version 2 or any later version

	$Source$
	$Revision$
	$Author$
	$Date$
**********************************************/

if (!isset($_SERVER['REQUEST_TIME_FLOAT'])) { $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true); }

if (version_compare(phpversion(), '5.3', '<'))
{
	header($_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error');
	exit('This software needs atleast <a href="http://gophp5.org/">PHP 5.3</a>');
}
set_include_path(str_replace('.'.PATH_SEPARATOR, '.'.PATH_SEPARATOR.dirname(dirname(__FILE__)).PATH_SEPARATOR, get_include_path()));

if (!defined('POODLE_BACKEND'))  { define('POODLE_BACKEND',  false); }
if (!defined('POODLE_SETUP'))    { define('POODLE_SETUP',    false); }
if (!defined('POODLE_UNIT_TEST')){ define('POODLE_UNIT_TEST',false); }
if (!defined('POODLE_HOSTS_PATH')){ define('POODLE_HOSTS_PATH','poodle_hosts/'); }
define('POODLE_CLI', false !== stripos(php_sapi_name(), 'cli'));
define('XMLHTTPRequest', (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && 'XMLHttpRequest' === $_SERVER['HTTP_X_REQUESTED_WITH']));
define('WINDOWS_OS', '\\' === DIRECTORY_SEPARATOR);

if (WINDOWS_OS) {
	$_SERVER = str_replace(DIRECTORY_SEPARATOR,'/',$_SERVER);
	function uri_dirname($path) { return str_replace(DIRECTORY_SEPARATOR,'/',dirname($path)); }
	// Workaround issue with IIS Helicontech APE which defines vars lowercased
	foreach ($_SERVER as $k => $v) $_SERVER[strtoupper($k)] = $v;
	// When using ISAPI with IIS, the value will be off if the request was not made through the HTTPS protocol.
	if (isset($_SERVER['HTTPS']) && 'off'===$_SERVER['HTTPS']) unset($_SERVER['HTTPS']);
} else {
	function uri_dirname($path) { return dirname($path); }
}

if (!function_exists('class_alias')) { function class_alias($original, $alias) { eval("class {$alias} extends {$original}{}"); } }

# Custom function to detect if array is associative
if (!function_exists('is_assoc')) { function is_assoc($a) { return (is_array($a) && array_keys($a) !== array_keys(array_keys($a))); } }

abstract class Poodle
{
	const
		VERSION    = '2.0.0.0',
		DB_VERSION = 20110000,
		CHARSET    = 'UTF-8',

		DBG_ALL         = 2147483647, # 64bit: 9223372036854775807
		DBG_MEMORY      = 1,
		DBG_PARSE_TIME  = 2,
		DBG_TPL_TIME    = 4,
		DBG_SQL         = 8,
		DBG_SQL_QUERIES = 16,
		DBG_JAVASCRIPT  = 32,
		DBG_PHP         = 64,
		DBG_AMF         = 128,
		DBG_EXEC_TIME   = 256,
		DBG_INCLUDED_FILES      = 268435456,
		DBG_DECLARED_CLASSES    = 536870912,
		DBG_DECLARED_INTERFACES = 1073741824;

	public static
		$DEBUG = 0,

		$UMASK = null, # octdec()?

		$COMPRESS_OUTPUT = false,

		$EXT  = null,
		$PATH = array(),

		$DIR_BASE  = '',
		$DIR_MEDIA = 'media/',

		$URI_ADMIN,
		$URI_BASE,
		$URI_INDEX,
		$URI_MEDIA,
		$UA_LANGUAGES;

	protected
		$CACHE,
		$IDENTITY;

	function __get($key)
	{
		if (property_exists($this,$key)) { return $this->$key; }
		$tmp = debug_backtrace(false/*,1*/);
		trigger_error("Undefined property: {$key} by: {$tmp[0]['file']}#{$tmp[0]['line']}");
		return null;
	}
/*
	private static
		$PROCESS_UID = 0,
		$PROCESS_OWNER = 'nobody';
*/
	public static function chmod($file, $mask=0666)
	{
		$m = umask(self::$UMASK);
		$r = chmod($file, $mask);
		umask($m);
		return $r;
	}

	public static function closeRequest($msg, $status_code=200, $uri=null, $box_msg=null)
	{
		if (POODLE_CLI) { echo $status_code.' '.$msg; exit; }
		if (XMLHTTPRequest)
		{
			header('Pragma: no-cache');
			header('Cache-Control: no-cache');
			Poodle_HTTP_Headers::setStatus($status_code);
			switch ($status_code) {
			case 201: if ($uri) { header('Location: '.$uri); } break;
			case 204: exit;
			}
			if ($box_msg) { Poodle_Notify::success($box_msg); }
			exit($msg);
		}
		if ($status_code > 400) { Poodle_Report::error($status_code, $msg); }
		if ($msg) { Poodle_Notify::success($msg); }
		Poodle_URI::redirect($uri);
	}

	public static function getFile($name, array $paths=array())
	{
		$dirs = $paths ? $paths : explode(PATH_SEPARATOR, get_include_path());
		foreach ($dirs as $dir) {
			$file = $dir.DIRECTORY_SEPARATOR.$name;
			if (is_file($file)) { return $file; }
		}
	}

	public static function shortFilePath($file)
	{
		static $paths;
		if (!$paths) { $paths = array_merge(array(self::$DIR_BASE), explode(PATH_SEPARATOR, preg_replace('#\.+'.PATH_SEPARATOR.'#', '', get_include_path()))); }
		return str_replace($paths, '', $file);
//		if (!$paths) { $paths = '#^('.str_replace(PATH_SEPARATOR,'|',get_include_path()).')#'; }
//		if (!$paths) { $paths = '#^('.implode('|',array_merge(array(self::$DIR_BASE), explode(PATH_SEPARATOR, preg_replace('#\.+'.PATH_SEPARATOR.'#', '', get_include_path())))).')#'; }
//		return preg_replace(self::$re_paths, '', $file);
	}

	public static function getConfig($cfg_dir=null)
	{
		$dir = mb_strtolower($cfg_dir ? $cfg_dir : $_SERVER['HTTP_HOST']);
		$config = array();

		if (!is_file(POODLE_HOSTS_PATH."{$dir}/config.php")) {
			if ($cfg_dir) {
				trigger_error('Poodle config not found');
				return false;
			}
			$dir = 'default';
		}

		if (is_file(POODLE_HOSTS_PATH."{$dir}/config.php")) {
			include(POODLE_HOSTS_PATH."{$dir}/config.php");
		}

		if ($config) {
			if (!isset($config['default']['cache_dir'])) {
				$config['default']['cache_dir'] = str_replace(DIRECTORY_SEPARATOR,'/',realpath(POODLE_HOSTS_PATH.$dir)).'/cache/';
			}
			if (!isset($config['default']['cache_uri'])) {
				$config['default']['cache_uri'] = 'file://'.$config['default']['cache_dir'];
			}
		}

		if (is_null(self::$UMASK)) {
			self::$UMASK = ('cgi-fcgi'==PHP_SAPI) ? 0022 : 0;
/*
			# Get the process information
			if (!WINDOWS_OS && function_exists('posix_getpwuid')) {
				# w32 get_current_user() returns process
				$pwuid = posix_getpwuid(posix_geteuid());
				self::$PROCESS_UID = posix_geteuid();
				self::$PROCESS_OWNER = array_shift($pwuid);
			}
			self::$UMASK = (preg_match('#(www-data|nobody|apache)#', self::$PROCESS_OWNER) || getmyuid() !== self::$PROCESS_UID) ? 0 : 0022;
*/
		}
		umask(self::$UMASK);

		return $config;
	}

	protected static $KERNEL = null;
	public static function getKernel() { return self::$KERNEL; }
	public static function loadKernel($kernel_name=null, array $cfg=array())
	{
		if (self::$KERNEL) { throw new Exception('Poodle Kernel already loaded'); }
		$name = $kernel_name;
		if (!$name && isset(self::$PATH[0])) {
			$name = self::$PATH[0];
		}
		$name = $name ? strtolower($name) : 'default';

//		$d = Poodle_PHP_INI::set('display_errors', 0);
		self::$COMPRESS_OUTPUT = true;

		$config = self::getConfig(isset($cfg['cfg_dir'])?$cfg['cfg_dir']:null);
		unset($cfg['cfg_dir']);
		$config = array_merge($config, $cfg);
		if ($config) {
			if (!isset($config[$name])) {
				if ($kernel_name) {
					// Kernel name was requested and therefore required. So we kill the process
					trigger_error("Poodle config[{$kernel_name}] not found", E_USER_ERROR);
				}
				$name = 'default';
			}
			if (isset($config['default'])) {
				$config[$name] = array_merge($config['default'], $config[$name]);
			}
			$config = isset($config[$name]) ? $config[$name] : array();
		}

		$class  = 'Poodle_Kernels_'.$name;
		self::$KERNEL = new $class($config);
		self::$KERNEL->init();

//		if (false !== $d) Poodle_PHP_INI::set('display_errors', $d);

		return self::$KERNEL;
	}

	protected function init(){}

	# destroy output buffering
	public static function ob_clean()
	{
		if ($i = ob_get_level()) {
			# Clear buffers:
			while ($i-- && ob_end_clean());
			if (!ob_get_level()) header('Content-Encoding: ');
		}
	}

	# autoload() ads a few milliseconds on each call
	public static function autoload($class_name)
	{
		//trigger_error('Autoload: '.$class_name);
		# split class_name into segments where the
		# first segment is the library or component
//		$class_name = ltrim($class_name,'\\');
		if (strpos($class_name, '\\')) {
			$path = explode('\\', $class_name);
			$namespace = implode('\\', array_slice($path,0,-1));
		} else {
			$path = explode('_', $class_name);
			$namespace = null;
		}
/*
		if (!preg_match('#^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$#', $class_name)) {
			# PEAR bug and such
			return;
		}
*/
		if ($path)
		{
			switch (strtolower($path[0]))
			{
			case 'zend': include(implode('/',$path).'.php');
			case 'pear': break;

			default:
				/** Default spl_autoload_register also lowercases the filename  */
				$path = array_map('strtolower', $path);

				/** When the class name is the directory itself add itself as filename  */
				if (!isset($path[2])) { $path[2] = $path[1]; }

				/** Temporary disable "failed to open stream: No such file or directory" warning */
				$level = error_reporting(error_reporting() & ~E_WARNING);
				include(implode('/',$path).'.php');
				error_reporting($level);

				if (!class_exists($class_name, false) && !interface_exists($class_name, false))
				{
					/** Last attempt to find class in global container directory */
					$lib = $path[0];
					array_shift($path);
					if ($path[0] === $path[1]) { array_shift($path); }
					$file = implode('_',$path);
					if ($interface = in_array('interface', $path)) {
						$file = $lib.'/interfaces/'.str_replace('_interface','',$file);
					} else {
						$file = $lib.'/classes/'.$file;
					}
					include($file.'.php');
					if ($interface && !interface_exists($class_name, false)) {
						if (class_exists('Poodle_PHP_INI', false)) Poodle_PHP_INI::set('display_errors', 1);
						eval('interface '.$class_name.'{}');
//						throw new Exception("Interface {$class_name} not found");
					}
					if (!$interface && !class_exists($class_name, false)) {
						if (class_exists('Poodle_PHP_INI', false)) Poodle_PHP_INI::set('display_errors', 1);
						throw new Exception("Class {$class_name} not found");
					}
				}
				break;
			}
		}
	}
}

//spl_autoload_register('Poodle::autoload');

class Poodle_Event
{
	public
		$target,
		$type;

	function __construct($type)
	{
		$this->type = $type;
	}
}

interface Poodle_Events_Interface
{
 	public function addEventListener($type, $function);
	public function dispatchEvent(Poodle_Event $event);
	public function removeEventListener($type, $function);
	public function triggerEvent($type, array $properties=array());
//	public function removeAllEventListeners($type=null);
}

/* PHP 5.4: php.net/traits
trait Poodle_Events
*/
abstract class Poodle_Events implements Poodle_Events_Interface
{
	protected $_poodle_events = array();

	public function addEventListener($type, $function)
	{
		$type = strtolower($type);
		if (!is_callable($function)) { trigger_error('Function for Event '.$type.' is not callable in '.get_class($this)); }
		else if (!isset($this->_poodle_events[$type])) { $this->_poodle_events[$type] = array($function); }
		else if (!in_array($function, $this->_poodle_events[$type], true)) { $this->_poodle_events[$type][] = $function; }
	}

	public function dispatchEvent(Poodle_Event $event)
	{
		$event->target = $this;
		$type = strtolower($event->type);
		if (!empty($this->_poodle_events[$type])) {
			foreach ($this->_poodle_events[$type] as $callback) { call_user_func($callback, $event); }
/*				try { call_user_func($callback, $event); }
				catch (Exception $e) { Poodle_LOG::error(__CLASS__, $e->getMessage()."\n".$e->getTraceAsString()); }*/
		}
//		else { trigger_error('Event type '.$type.' is empty in '.get_class($this)); }
	}

	public function removeEventListener($type, $function)
	{
		$type = strtolower($type);
		if (empty($this->_poodle_events[$type])) { trigger_error('Event type '.$type.' is empty in '.get_class($this)); }
		else {
			$key = array_search($function, $this->_poodle_events[$type], true);
			if (false !== $key) { unset($this->_poodle_events[$type][$key]); }
		}
	}

	public function triggerEvent($type, array $properties=array())
	{
		$this->dispatchEvent(new Poodle_Event($type));
	}

	protected function removeAllEventListeners($type=null)
	{
		if ($type) unset($this->_poodle_events[strtolower($type)]);
		else $this->_poodle_events = array();
	}
}

class Poodle_PATH_INFO implements ArrayAccess, Countable, Iterator
{
	protected $path;
	function __construct($path)
	{
		$this->path = explode('/', substr($path, 1));
//		$this->path = explode('/', trim($path, '/'));
	}
	function __toString()     { return '/'.implode('/',$this->path); }
	# Iterator
	public function key()     { return key($this->path); }
	public function current() { return current($this->path); }
	public function next()    { return next($this->path); }
	public function rewind()  { return reset($this->path); }
	public function valid()   { return (null !== key($this->path)); }
	# ArrayAccess
	public function offsetExists($i) { return array_key_exists($i, $this->path); }
	public function offsetGet($i)    { return $this->offsetExists($i) ? $this->path[$i] : null; }
	public function offsetSet($i,$v) {}
	public function offsetUnset($i)  {}
	# Countable
	public function count()   { return count($this->path); }

	public function getArrayCopy() { return $this->path; }
}

class Poodle_Date extends Poodle_DateTime {}
class Poodle_Time extends Poodle_DateTime {}
class Poodle_Timestamp extends Poodle_DateTime {}

#
# Load default server behavior
#

setlocale(LC_ALL, 'C');

if (POODLE_CLI) { include('bootstrap_cli.php'); }

//if (empty($_SERVER['HTTP_USER_AGENT']) || !preg_match('#^[a-zA-Z]#', $_SERVER['HTTP_USER_AGENT']))
//{
//	Poodle_HTTP_Headers::setStatus(412);
//	exit('You must send a correct User-Agent header so we can identify your browser');
//}

# Nagios check_http, hyperspin.com and paessler.com/support/kb/questions/12
if (preg_match('#(check_http/|hyperspin\.com|paessler.com)#i', $_SERVER['HTTP_USER_AGENT']))
{
	exit('OK');
}

# http://support.microsoft.com/kb/293792
if ('contype' === $_SERVER['HTTP_USER_AGENT'])
{
	Poodle_HTTP_Headers::setContentType('application/'.(strpos($_SERVER['REQUEST_URI'], 'pdf')?'pdf':'octet-stream'));
	exit;
}

header('X-Content-Type-Options: nosniff'); # IE8 google.com/search?q=X-Content-Type-Options
header('X-UA-Compatible: IE=edge');
//header('X-UA-Compatible: chrome=1, IE=edge'); # IE8 Google Chrome Frame http://code.google.com/chrome/chromeframe/
header('imagetoolbar: no'); # IE
header('X-Powered-By: Poodle WCMS using PHP');

putenv('HOME'); # cannot open /root/*: Permission denied
//if (!getenv('MAGIC')) { putenv('MAGIC='.dirname(__FILE__).(WINDOWS_OS?'/win32':'').'/magic.mime'); } # /usr/share/misc/magic

Poodle_PHP_INI::init();

if (version_compare(phpversion(), '6', '<'))
{
	if (!defined('FILE_TEXT'))  { define('FILE_TEXT', 32); }
	if (!defined('FILE_BINARY')){ define('FILE_BINARY', 64); }
	if (!function_exists('is_binary'))  { function is_binary($v)  { return is_string($v) && preg_match('#[\x00-\x08\x11\x12\x14-\x1F\x7F]#',$v); } }
	if (!function_exists('is_unicode')) { function is_unicode($v) { return is_string($v) && preg_match('#^.*$#Du',$v); } }
}

if (empty($_SERVER['SERVER_PROTOCOL'])) { $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; }
if (isset($_SERVER['REDIRECT_STATUS']) && 200 == $_SERVER['REDIRECT_STATUS'])
{
	if (empty($_SERVER['PATH_INFO']) && isset($_SERVER['REDIRECT_PATH_INFO']))
	{
		$_SERVER['PATH_INFO'] = $_SERVER['REDIRECT_PATH_INFO'];
	}
	unset($_SERVER['REDIRECT_PATH_INFO']);
	unset($_SERVER['REDIRECT_STATUS']);
	unset($_SERVER['REDIRECT_QUERY_STRING']);
	unset($_SERVER['REDIRECT_URL']);
}
if (empty($_SERVER['HTTP_HOST'])) { $_SERVER['HTTP_HOST'] = (empty($_SERVER['SERVER_NAME']) ? '127.0.0.1' : $_SERVER['SERVER_NAME']); }
if (empty($_SERVER['PATH_INFO'])) { $_SERVER['PATH_INFO'] = !empty($_GET['PATH_INFO']) ? $_GET['PATH_INFO'] : '/'; }
unset($_SERVER['PATH_TRANSLATED']); # it's incorrect
unset($_GET['PATH_INFO']);
/*
// DOCUMENT_ROOT fix for IIS Webserver
if (empty($_SERVER['DOCUMENT_ROOT'])) {
	if (isset($_SERVER['SCRIPT_FILENAME'])) {
		$_SERVER['DOCUMENT_ROOT'] = str_replace('\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF'])));
	} else if (isset($_SERVER['PATH_TRANSLATED'])) {
		$_SERVER['DOCUMENT_ROOT'] = str_replace('\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF'])));
	} else {
		// define here your DOCUMENT_ROOT path if the previous fails (e.g. '/var/www')
		$_SERVER['DOCUMENT_ROOT'] = '/';
	}
}
*/
# Poodle entries
$_SERVER['HTTP_SEARCH_QUERY'] = '';
if (!empty($_GET['q'])) {
	$_SERVER['HTTP_SEARCH_QUERY'] = urldecode($_GET['q']);
} else if (!empty($_SERVER['HTTP_REFERER']) && preg_match('#[\?&](p|q|query|text)=([^&]+)#', $_SERVER['HTTP_REFERER'], $path)) {
	$_SERVER['HTTP_SEARCH_QUERY'] = urldecode($path[2]);
	$_SERVER['HTTP_REFERER'] = preg_replace('#^([^\?;]+).*$#D', '$1', $_SERVER['HTTP_REFERER']).'?'.$path[1].'='.$path[2];
}
$_SERVER['HTTP_QUERY_STRING'] = empty($_SERVER['QUERY_STRING'])?'':'?'.$_SERVER['QUERY_STRING'];
$_SERVER['SERVER_MOD_REWRITE'] = !empty($_SERVER['SERVER_MOD_REWRITE']);
unset($_SERVER['REDIRECT_SERVER_MOD_REWRITE']);
if (empty($_SERVER['SERVER_PROTOCOL_VERSION'])) {
	$_SERVER['SERVER_PROTOCOL_VERSION'] = floatval(preg_replace('#^.*/([0-9\\.]+).*$#D', '$1', $_SERVER['SERVER_PROTOCOL']));
}

# Harden PHP
/*$_REQUEST = array();
$_GET = new Poodle_Input_GET($_GET);
if ($_POST || 'POST' === $_SERVER['REQUEST_METHOD'])
{
	$_POST = new Poodle_Input_POST($_POST);
	if ($_FILES) { $_FILES = new Poodle_Input_FILES($_FILES); }
}*/

#
# Let's configure the system
#

// IPv4 | IPv6 loopback | IPv6 link-local | IPv6 ULA
if (!isset($_SERVER['SERVER_ADDR']) && isset($_SERVER['LOCAL_ADDR'])) $_SERVER['SERVER_ADDR'] = $_SERVER['LOCAL_ADDR'];
if (preg_match('#^(10|127.0.0|172.(1[6-9]|2\d|3[0-1])|192\.168|::1[:$]|fe80:|fc00:)#', $_SERVER['SERVER_ADDR'])
 || preg_match('#^(10|127.0.0|172.(1[6-9]|2\d|3[0-1])|192\.168|::1[:$]|fe80:|fc00:)#', $_SERVER['REMOTE_ADDR']))
{               #  ^^ 1000::/8
	Poodle::$DEBUG = Poodle::DBG_ALL; // not what you want for intranets
}

$path = str_replace('\\','/',getcwd());

Poodle::$DIR_BASE = $path.DIRECTORY_SEPARATOR;

Poodle::$URI_INDEX = $_SERVER['SCRIPT_NAME'];
$path = str_replace($path, '', $_SERVER['SCRIPT_FILENAME']);
if ('/' !== uri_dirname($path)) {
	Poodle::$URI_ADMIN = Poodle::$URI_INDEX;
	Poodle::$URI_INDEX = str_replace($path,'/index.php',Poodle::$URI_INDEX);
} else {
	Poodle::$URI_ADMIN = rtrim(uri_dirname(Poodle::$URI_INDEX),'/').'/admin/index.php';
}

Poodle::$URI_BASE = rtrim(uri_dirname(Poodle::$URI_INDEX),'/');

if ($_SERVER['SERVER_MOD_REWRITE']) {
	Poodle::$URI_ADMIN = uri_dirname(Poodle::$URI_ADMIN);
	Poodle::$URI_INDEX = uri_dirname(Poodle::$URI_INDEX);
	$_SERVER['PHP_SELF'] = preg_replace("#^{$_SERVER['SCRIPT_NAME']}/*#",rtrim(uri_dirname($_SERVER['SCRIPT_NAME']),'/').'/',$_SERVER['PHP_SELF']);
}

Poodle::$URI_ADMIN .= '/';
Poodle::$URI_INDEX = rtrim(Poodle::$URI_INDEX,'/').'/';
Poodle::$URI_MEDIA = Poodle::$URI_BASE.'/media/';

# tools.ietf.org/html/rfc2616#section-3.9
Poodle::$UA_LANGUAGES = (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])
	? ''
	: preg_replace('#;q=(?!0\\.)([0-9]*)\\.?#', ';q=0.$1',strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE'])));

if ('/' !== $_SERVER['PATH_INFO']) {
	# Detect and strip ISO 639-1 language name + optional ISO-3166-1 country code (RFC 1766)
	if (preg_match('#^/([a-z]{2}(?:-[a-z]{2})?)(/.*)?$#D', $_SERVER['PATH_INFO'], $path)) {
		if (empty($path[2])) {
			Poodle_HTTP_Headers::setLocation($path[1].'/'.$_SERVER['HTTP_QUERY_STRING'], 301);
			exit;
		}
		Poodle::$UA_LANGUAGES = $path[1].';q=9,'.Poodle::$UA_LANGUAGES;
		$_SERVER['PATH_INFO'] = $path[2];
	}

	# Detect output extension and split directories
	if ('/' !== $_SERVER['PATH_INFO']) {
		if (preg_match('#^(/.+)(?:/|\.([a-z0-9]+))$#D', $_SERVER['PATH_INFO'], $path)) {
			$_SERVER['PATH_INFO'] = $path[1];
			if (isset($path[2])) {
				Poodle::$EXT = $path[2];
			} else {
				$_SERVER['PATH_INFO'] .= '/';
			}
		}
	}
}
Poodle::$PATH = new Poodle_PATH_INFO($_SERVER['PATH_INFO']);

unset($path);
